package top.houry.linklist;

/**
 * @Desc
 * @Author houruiyang
 * @Date 2022/9/9
 **/
public class BinarySearch {


    public boolean binarySearchTest(int begin, int end, int target) {


        while (begin + 1 < end) {
            int middle = begin + (end - begin) / 2;
            if (target == middle) {
                return true;
            }
            if (target < middle) {
                end = middle;
            }

            if (target > middle) {
                begin = middle;
            }


        }
        if (begin == target || end == target) {
            return true;
        }

        return false;
    }
}
